{% extends 'base.html' %}


{% block  title  %}
首页
{% endblock %}


{% block head %}
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
    <!-- <link rel="stylesheet" href="{{ url_for('static',filename='css/index.css') }}"> -->
    <style type="text/css"> 
    .main ul{ margin:0; padding:0;  }
    .main p{ white-space:nowrap; text-overflow:ellipsis; overflow:hidden;}
    .main li{ width: 100%;
        padding: 2px;
        overflow: hidden;
        border-bottom:2px solid #eee;
        height:40px;
        list-style: none;
         /*display:inline;*/
         /*border-bottom:1px solid #555555;*/
    } 
    .question-title{
        line-height: 30px;
        margin-left:10px;
        font-weight: 900;
        
        float: left; 
    }
    .url-title{
        line-height: 30px;
        margin-left:10px;
        /*color: #259*/
        float: left; 
    }
    .question-content{
        line-height: 30px;
        margin-right: 10px;
        float: right; 
    }
    #hide-center {
    width:308px;
    height:300px;
    position:absolute;
    right:0;
    left:0;
    bottom:0;
    top:0;
    margin:auto;
    display:none;
    z-index:1;
    }
    #hide-center #close {
        width:20px;
        height:20px;
        display:inline-block;
        color: black;
    }
    </style>  
{% endblock %}

{% block  main  %}

{% if judge_resout %}
<script>
    function ale() { 
        //弹出一个对话框 
        alert({{judge_resout|tojson}}); 
      
    }
 ale()   
</script>
{% endif %}




    <li>
    <div class='pro_append'>
        <button type="button" style="margin-top: 5px;"><a href="{{ url_for('append') }}">添加项目</a></button>      
    </div>
    </li>
    <ul class="question-ul">                      
      <!--   <li>
            <div class="side-question">
                <p class="new" style="color:#33ff00;font-style: italic;margin:5px;float: left;">new</p>


                <p class="question-title" style="width: 150px"><a href="#" style="color: black;">青岛温馨巴士</a></p>
                <p class="url-title" style="width: 250px"><a href="#" style="color: #0000ff">http://www.dreamdu.com/css/property_list-style-type/</a></p>
                <p class="url-title" ><a href="#" style="color: #ff6666">优先级【1】</a></p>
                <p class="url-title" ><a href="#" style="color: black;">正在处理</a></p>
            
                <p class="question-content"><a href="#">下载</a></p>
            </div>
        </li> 
 -->

        {% for question in questions %}

            <li>
            <div class="side-question">
                <!-- <p class="new" style="color:#33ff00;font-style: italic;margin:5px;float: left;">new</p> -->
                <p class="question-title" style="width: 80px"><a href="{{url_for('detail',question_id=question.id) }}" style="color: black;">{{ question.title }}</a></p>
                <p class="url-title" style="width: 100px"><a href="{{question.url}}" target="_blank" style="color: #0000ff">{{ question.url }}</a></p>
                <p class="url-title" style="color: #ff6666">优先级【{{ question.nub }}】</a></p>
                {% if question.zhuangtai %}
                    {% if question.zhuangtai == 'pending' %}
                        <p class="url-title" style="color:#33ff00;">{{ question.zhuangtai }}</a></p>
                    {% elif question.zhuangtai =='sleep' %}  
                        <p class="url-title" style="color:black;">{{ question.zhuangtai }}</a></p>
                    {% else %}  
                        <p class="url-title" style="color:red;">{{ question.zhuangtai }}</a></p>
                    {% endif %}
                {% else %}   
                    <p class="url-title" style="color:blue;width: 50px">待处理</a></p>
                {% endif %}
                {% if question.author %}    
                    <p class="url-title" style="color: black;width: 60px">{{ question.author.username }}</a></p>
                {% else %}    
                    <p class="url-title" style="color: #33ff00;width: 60px">处理人</a></p>
                {% endif %}

                <p class="url-title" style="color: black;;width: 125px">{{ question.create_time}}</a></p>

                {% if user %}
                    <p class="url-title"><a id="login" style="font-size: 15px;" href="#" onclick="msgbox({{ question.id|tojson }})" >定时执行</a></p>
                {% else %}
                    <p class="url-title"><a id="login" style="font-size: 15px;" href="#" onclick="confirmAct()">定时执行</a></p>
                {% endif %} 
                <p class="url-title"><a href="{{url_for('run_time',question_id=question.id)}}" ><span class="glyphicon glyphicon-hand-left" title='查看设置时间' aria-hidden="true"></span></a></p>

                <p class="url-title"><a href="{{url_for('delete_task',question_id=question.id)}}" onclick="return confirmAct1l();"><span class="glyphicon glyphicon-refresh" title="重置运行时间" aria-hidden="true"></span></a></p>
                
                
                <p class="question-content">
                    <a href="{{url_for('download_data',question_id=question.id)}}">下载数据</a>
                </p>
                {% if user %}
                    <p class="question-content">
                        <a href="{{url_for('delete_data',question_id=question.id) }}" onclick="return confirmAct1();">删除项目</a>
                    </p>
                {% else %}
                    <p class="question-content">
                        <a href="{{url_for('delete_data',question_id=question.id) }}" onclick="return confirmAct();">删除项目</a>
                    </p>
                {% endif %}    

            </div>

            </li> 
        {% endfor %}
    </ul>


<!-- 隐藏窗口 -->

<div id="hide-center">
    <div class="timer" style="width: 600px;height:380px;box-shadow: -1px 2px 10px #888888; border: 1px solid #CECECE; margin-top: -100px;margin-left: -200px;background: white; ">
        <a  id="close" style="float: right;" href="#" onclick="msgbox(0); return false;">X</a>
            <form action="{{ url_for('whiletask') }}" method="post">
                <input id="question_id" type="hidden" name='question_id'/>
                <div class="post_data" style="margin: 20px; margin: 20px; width: 92%; height: 50px;"> 
                    <span class="label label-default" style="float:left;margin-right: 10px;  height: 25px; width: 70px; background: green;line-height: 25px; font-size: 24">运行模式</span>
                        <select id="mode" name="mode" style="height: 25px; margin-right: 10px;float:left; " onChange="disinput(this)">
                            <option value="interval">周期运行</option>
                            <option value="timer">指定时间运行</option>        
                        </select>
                </div> 
                        
                <div class="starttime" style="margin: 20px;border: 1px solid #CECECE; margin-top: 10px; width: 92%; height: 50px;">
                        <div style="float: left;margin-left: 20px;font-size: 20px; font-weight: 20; line-height: 50px;"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
                            下次运行时间
                        </div>
                        <div style="float: right;margin-right: 20px; font-size: 16px; margin-top: 10px;">
                                *
                            <input type="datetime-local" id="mydate" name='time' style="" /> 
                        </div>
                    </div>

                    <div id="ttime" style="margin: 20px;border: 1px solid #CECECE; margin: 20px; width: 92%; height: 50px;">
                        <div style="float: left;margin-left: 20px;font-size: 20px; font-weight: 20; line-height: 50px;" >
                            设置时间间隔
                        </div>
                        <div style="float: right;margin-right: 20px; font-size: 16px; margin-top: 10px;">
                            
                                <input type="number" placeholder="周" name="weeks" class="form-control" min="0" max="" style="width: 55px;float: left;">
                                <input type="number" placeholder="天" name="day" class="form-control" min="0" max="31" style="width: 55px;float: left;">
                                <input type="number" placeholder="时" name="hours" class="form-control" min="0" max="24" style="width: 55px;float: left;">
                                <input type="number" placeholder="分" name="minute" class="form-control" min="0" max="60" style="width: 55px;float: left;">
                                <input type="number" placeholder="秒" name="second" class="form-control" min="0" max="60" style="width: 55px;float: left;">
                                
                        </div>
                    </div>

                    <div class="starttime" style="margin: 20px;border: 1px solid #CECECE; margin-top: 20px; width: 92%; height: 50px;">
                            <div style="float: left;margin-left: 20px;font-size: 20px; font-weight: 20; line-height: 50px;">
                            下次结束时间
                            </div>
                            <div style="float: right;margin-right: 20px; font-size: 16px; margin-top: 10px;">
                                <input type="datetime-local" name='end_time' style="" value="" /> 
                            </div>
                    </div>

                    <div class="form-group" style="margin-right: 30px;margin-top: 20px; margin-left: 260px">
                                <button class="btn btn-primary">提交</button>
                    </div>
                    </form>
                </div>
    </div>
</div>




<script>

function msgbox(n){
    document.getElementById('hide-center').style.display=n?'block':'none';     /* 点击按钮打开/关闭 对话框 */
    document.getElementById("question_id").value=n;
}
</script>
 
<script type="text/javascript">
    

function disinput(obj){
    if(obj.value=="timer"){
        document.getElementById("ttime").style.display="none";
    }else{document.getElementById("ttime").style.display="block";}
}



</script>    
<script type="text/javascript" language="javascript"> 

function confirmAct() 
{ 
    if(confirm('需要用户管理权限')) 
    { 
        return true; 
    } 
    return false; 
} 
function confirmAct1() 
{ 
    if(confirm('请确定删除项目')) 
    { 
        return true; 
    } 
    return false; 
} 
function confirmAct1l() 
{ 
    if(confirm('请确定重置运行时间')) 
    { 
        return true; 
    } 
    return false; 
}


</script>





<script>
function myFunction() {
    var x =  getNowFormatDate();
    document.getElementById("mydate").value=x;  
}

function getNowFormatDate() {
        var now = new Date();  
          
        var year = now.getFullYear();       //年  
        var month = now.getMonth() + 1;     //月  
        var day = now.getDate();            //日  
          
        var hh = now.getHours();            //时  
        var mm = now.getMinutes();          //分  
        var ss = now.getSeconds();           //秒  
          
        var clock = year + "-";  
          
        if(month < 10)  
            clock += "0";  
          
        clock += month + "-";  
          
        if(day < 10)  
            clock += "0";  
              
        clock += day + "T";  
          
        if(hh < 10)  
            clock += "0";  
              
        clock += hh + ":";  
        if (mm < 10) clock += '0';   
        clock += mm;   
           
        return(clock);    
}

myFunction()
</script>
{% endblock %}